package com.dna.common.net;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.SocketException;
import java.net.SocketImpl;

public class PlugableServerSocket extends ServerSocket {

	public PlugableServerSocket() throws IOException {
		super();
	}
	
	public PlugableServerSocket(int i) throws IOException {
		super(i);
    }

	public PlugableServerSocket(int i, int j) throws IOException {
	    super(i,j);
	}

	public PlugableServerSocket(int i, int j, InetAddress inetaddress) throws IOException
	{
		super(i,j,inetaddress);
	}
	
	@Override
	public PlugableSocket accept() throws IOException {
		if(isClosed())
            throw new SocketException("Socket is closed");
        if(!isBound())
        {
            throw new SocketException("Socket is not bound yet");
        } else
        {
        	PlugableSocket socket = new PlugableSocket((SocketImpl)null);
            super.implAccept(socket);
            return socket;
        }
	}

}
